


namespace chatroom{
    #pragma db object table("user")
    class User{
        public:
            User(){}
            //用户新增，通过nickname和passwd新增
            User(const std::string& uid,const std::string& nickname,const std::string& passwd):_user_id(uid),_nickname(nickname),_passwd(passwd){}
            //通过电话号码新增
            User(const std::string& uid,const std::string& phone):_user_id(uid),_phone(phone),_nickname(uid){}
            
            void set_user_id(const std::string& val){_user_id = val}
            std::string get_user_id(){return _user_id}

            void set_nickname(const std::string& val){_nickname = val}
            odb::nullable<std::string> get_nickname(){
                if(!_nickname)return std::string();
                return *_nickname;
            }

            void set_phone(const std::string& val){_phone = val}
            odb::nullable<std::string> get_phone(){
                if(!_phone)return std::string();
                return *_phone;
            }

            void set_passwd(const std::string& val){_passwd = val}
            odb::nullable<std::string> get_passwd(){
                if(!_passwd)return std::string();
                return *_passwd;
            }

            void set_avatar_id(const std::string& val){_avatar_id = val}
            odb::nullable<std::string> get_avatar_id(){
                if(!_avatar_id)return std::string();
                return *_avatar_id;
            }

            void set_desc(const std::string& val){_description = val}
            odb::nullable<std::string> get_desc(){
                if(!_description)return std::string();
                return *_description;
            }
        private:
        friend class odb::access;
        #pragma db id auto
        unsigned long _id;
        #pragma db type("VARCHAR(64)") index unique
        std::string _user_id;
        #pragma db type("VARCHAR(64)") index unique
        odb::nullable<std::string> _nickname;
        #pragma db type("VARCHAR(64)") index unique
        odb::nullable<std::string> _phone;
        odb::nullable<std::string> _description;
        #pragma db type("VARCHAR(64)")
        odb::nullable<std::string> _passwd;
        #pragma db type("VARCHAR(64)")
        odb::nullable<std::string> _avatar_id;
    };
}